<?php
/**
 * Created by PhpStorm.
 * User: Frings
 * Date: 2017-10-09
 * Time: 22:51
 */

namespace app\models;


use app\librarys\DbCacheUtility;

class Area
{
    public static function getAreaByLevel($level)
    {
        $sql = 'select id,parent_id,level,area_name from t_area where level = :level';
        $cmd = \Yii::$app->db->createCommand($sql);
        $cmd->bindValue(':level', $level);
        $items = DbCacheUtility::queryAll($cmd);
        return $items;
    }

    public static function getAreaByParentId($parent_id)
    {
        $sql = 'select id,parent_id,level,area_name from t_area where parent_id = :parent_id';
        $cmd = \Yii::$app->db->createCommand($sql);
        $cmd->bindValue(':parent_id', $parent_id);
        $items = DbCacheUtility::queryAll($cmd);
        return $items;
    }
}